<!DOCTYPE html>
<html lang="zh-cmn-Hans">
    <head>
        <title>绑定畅校园</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
        <meta name="renderer" content="webkit">
        <meta http-equiv="Cache-Control" content="no-siteapp">
        <meta name="keywords" content="西邮,西邮图书馆查询,畅校园,一站式校园生活平台,西邮图书馆">
        <meta name="description" content="西邮,西邮图书馆查询系统,畅校园,一站式校园生活平台,西邮图书馆">
        <meta name="author" content="droiz, zhengrenzhe@creatshare.com">
        <meta name="robots" content="index, follow">
        <link rel="stylesheet" href="css/stylesheets/style.css">
    </head>
    <body data-openid="zhengrenzhe">
        <header class="bind-nav">
            <span>绑定畅校园</span>
        </header>

        <section class="bind-not-logined">
            <form class="bind-login-form">
                <input type="text" autocapitalize="characters" autocorrect="off" autofocus="autofocus" class="bind-input bind-input-u" placeholder="学号(记得加S哦)">
                <input type="password" class="bind-input bind-input-p" placeholder="密码(图书馆)">
                <span class="bind-send bind-btn">绑定</span>
            </form>
        </section>

    </body>
    <script src="js/zepto.min.js"></script>
    <script src="js/touch.js"></script>
    <script>
        !(function( w, d, $ ){
            var OpenID = $( 'body' ).attr( 'data-openid' );

            if( !OpenID ){
                alert( '您必须在畅校园微信平台中打开该页面才可完成绑定。' );
                location.replace( 'search.html' );
                return false;
            }

            $( '.bind-input-u' ).on('input', function(){
                this.value = this.value.toLocaleUpperCase();
            });

            $( '.bind-btn' ).click(function(){
                var username = $( '.bind-input-u' ).val(),
                    password = $( '.bind-input-p' ).val();

                if( !username || !password ) return false;

                $.ajax({
                    'url': 'http://test.changxiaoyuan.com/index.php',
                    'data': {
                        'username': username,
                        'password': password,
                        'OpenID'  : OpenID,
                        'do'      : 'user',
                        'appkey'  : '4107762472'
                    },
                    'dataType': 'jsonp',
                    'success': function( data ){
                        alert( data.msg );
                        // TODO
                        location.replace( '' );
                    }
                })
            });
        })( window, document, Zepto );
    </script>
</html>
